package com.example.requrstTest;

import org.springframework.web.bind.annotation.*;


import java.util.Arrays;
import java.util.List;

@RestController
public class RequestController {
    @RequestMapping("/param1")
    public String param1(String userName) {
        System.out.println("接收到的参数: "+userName);
        return "1接收到的参数："+userName;
    }
    @RequestMapping("/param2")
    public String param2(Integer age) {
        return "2接收到的参数："+age;
    }
    @RequestMapping("/param3")
    public String param3(int age){
        return "3接收到参数: "+ age;
    }

    @RequestMapping("/param4")
    public String param4(String userName, String password){
        return "接收到参数userName:"+ userName +", password: "+password;
    }

    @RequestMapping("/param5")
    public String param5(UserInfo userInfo){
        System.out.println(userInfo.getUserName());

        return "接收到参数userInfo:"+ userInfo;
    }


    @RequestMapping("/param6")
    public String param6(@RequestParam(value = "userName", required = false) String name, String password){
        return "接收到参数name:"+ name +", password: "+password;
    }

    @RequestMapping("/param7")
    public String param7(String[] arrParams){
        return "接收到参数arrParams:"+ Arrays.toString(arrParams);
    }

    @RequestMapping("/param8")
    public String param8(@RequestParam("listParam") List<String> listParam){
        return "接收到参数listParam:"+ listParam;
    }


    @RequestMapping("/param9")
    public String param9(@RequestBody UserInfo userInfo){
        return "接收到参数userInfo:"+ userInfo;
    }


    @RequestMapping("/param10/{articleId}")
    public String param10(@PathVariable("articleId") Integer articleId){
        return "接收到参数articleId:"+ articleId;
    }
}
